//
//  MovieTableViewCell.m
//  快乐一点通
//
//  Created by cjp on 16/8/12.
//  Copyright © 2016年 cjp. All rights reserved.
//

#import "MovieTableViewCell.h"
#import "MovieModel.h"
#import <UIImageView+WebCache.h>

@interface MovieTableViewCell ()
/** 中间图片 */
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
/** 播放次数 */
@property (weak, nonatomic) IBOutlet UIButton *play_countButton;
/** 点赞次数 */
@property (weak, nonatomic) IBOutlet UIButton *vote_countButton;
/** 评论次数 */
@property (weak, nonatomic) IBOutlet UIButton *comment_countButton;
/** 标题 */
@property (weak, nonatomic) IBOutlet UILabel *movieTextLabel;

@end

@implementation MovieTableViewCell

- (void)setMovie:(MovieModel *)movie{
    
    _movie = movie;
    
    self.movieTextLabel.text = movie.title;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:movie.image] placeholderImage:nil];
    
    [self.play_countButton setTitle:[NSString stringWithFormat:@"%zd",movie.play_count] forState:UIControlStateNormal];
    [self.vote_countButton setTitle:[NSString stringWithFormat:@"%zd",movie.vote_count] forState:UIControlStateNormal];
    [self.comment_countButton setTitle:[NSString stringWithFormat:@"%zd",movie.comment_count] forState:UIControlStateNormal];
    
}

- (void)setFrame:(CGRect)frame{
    
    frame.origin.x = MovieCellMargin;
    frame.size.width -= 2 * frame.origin.x;
    frame.size.height -= MovieCellMargin - 2;
    frame.origin.y += MovieCellMargin;
    
    [super setFrame:frame];
}

@end
